<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <link rel="icon" type="image/x-icon" href="/signin/favicon.ico"/>
    <title>登录</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        ul, li, i {
            list-style: none;
            font-style: normal
        }

        form {
            width: 500px;
            margin: 30px auto;
            color: #6C6C6C;
        }

        p {
            height: 30px;
            line-height: 30px;
            margin-bottom: 26px;
            position: relative;
        }

        label {
            float: left;
            width: 80px;
            text-align: right;
            font-size: 14px;
        }

        span {
            font-size: 12px;
        }

        span b {
            font-weight: 400;
        }

        #sub {
            list-style: none;
            background-color: #2d8cf0;
            border: 1px solid #2d8cf0;
            color: #fff !important;
            margin-top: 0px;
            line-height: 36px;
            height: 36px;
            width: 120px;
            display: inline-block;
            text-align: center;
            text-decoration: none;
            vertical-align: middle;
            cursor: pointer;
            font-size: 14px;
            font-weight: 700;
            border-radius: 2px;
            padding: 0 20px;
            margin-left: 80px;
        }

        #home {
            list-style: none;
            background-color: #2d8cf0;
            border: 1px solid #2d8cf0;
            color: #fff !important;
            margin-top: 0px;
            line-height: 36px;
            height: 36px;
            width: 120px;
            display: inline-block;
            text-align: center;
            text-decoration: none;
            vertical-align: middle;
            cursor: pointer;
            font-size: 14px;
            font-weight: 700;
            border-radius: 2px;
            padding: 0 20px;
            margin-left: 50px;
        }

        p input {
            float: left;
            font-size: 12px;
            color: #6C6C6C;
            width: 300px;
            vertical-align: middle;
            border: 1px solid #ddd;
            height: 24px;
            line-height: 24px;
            padding: 3px 10px;
            margin-right: 8px;
        }

        p span {
            display: none;
            font-size: 14px;
            color: #ff5243;
            position: absolute;
            top: 28px;
            left: 80px;
        }

        span img {
            width: 16px;
            margin-bottom: -3px;
        }

        p.err input {
            border-color: #ff5243;
        }

        p.err span {
            display: block;
        }

        .step {
            width: 800px;
            margin: 0 auto;
            margin-top: 60px;
            position: relative;
        }

        .step:after {
            display: block;
            content: '.';
            height: 0;
            clear: both;
            visibility: hidden;
        }

        .step li {
            float: left;
            width: 33%;
            height: 54px;
            position: relative;
        }

        .ul-line {
            height: 3px;
            background: #b9b9b9;
            display: block;
            margin-top: 14px;
            line-height: 1;
            overflow: hidden;
        }

        .ul-icon {
            height: 50px;
            position: absolute;
            top: 0;
            width: 150px;
            text-align: center;
            left: -25px;
        }

        .iconfont {
            display: block;
            width: 30px;
            height: 30px;
            margin: 0;
            line-height: 30px;
            background: #fff;
            padding: 0 10px;
            position: absolute;
            top: 0;
            left: 0;
            text-shadow: 1px 1px 2px #fff, 0 0 0 #ccc, 1px 1px 2px #fff;
            background: #FFFFFF;
        }

        .iconfont:before {
            display: block;
            content: '';
            position: absolute;
            width: 30px;
            height: 30px;
            background: #b7b7b7;
            transform: rotate(45deg);
            border-radius: 6px;
        }

        .ul-number {
            font-size: 14px;
            line-height: 14px;
            position: absolute;
            top: 7px;
            left: 0;
            padding: 0 20px;
            font-weight: 700;
            color: #fff;
        }

        .step span {
            display: block;
            height: 30px;
            line-height: 30px;
            position: relative;
            text-shadow: 0 1px 0 #fff;
            top: 34px;
            left: -50px;
            color: #b7b7b7;
            font-size: 14px;
        }

        .step .step-end {
            position: absolute;
            top: 0;
            right: -140px;
            width: 150px;
            zoom: 1;
        }

        .step li .iconfont:before {
            background: #00C1DE;
        }

        .step li span {
            color: #b7b7b7;
        }

        .step li .ul-line {
            background: #b7b7b7;
        }

        .step .fir .iconfont:before {
            background: #00C1DE;
        }

        .step li:nth-of-type(1) .ul-line {
            background: #00C1DE;
        }

        .step li:nth-of-type(2) .ul-line {
            background: #00C1DE;
        }

        .step .active span {
            color: #00C1DE;
        }

        .step .step-end span {
            color: #b7b7b7;
        }

        .step .step-end .iconfont:before {
            background: #b7b7b7;
        }

        .div-bar {
            background: #2d8cf0;
            width: 100%;
            height: 50px;
            text-align: center;
            line-height: 50px;
            font-size: 20px;

        }

        #mitit {
            font-weight: 400;
            margin-left: 100px;
            color: #c3c3c3;
        }
    </style>
</head>
<body>
<div class="div-bar"><font color="white">忘记密码</font></div>
<ul class="step">
    <li class="fir active">
        <div class="ul-line"></div>
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">1</i>
            <span>验证身份</span>
        </div>
    </li>
    <li class="active">
        <div class="ul-line"></div>
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">2</i>
            <span>发送邮件</span>
        </div>
    </li>
    <li class="active">
        <div class="ul-line"></div>
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">3</i>
            <span>找回密码</span>
        </div>
    </li>
    <li class="step-end">
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">√</i>
            <span>完成</span>
        </div>
    </li>
</ul>
<form>
    <p class="pwd1">
        <label>新密码：</label>
        <input type="text" id="pass1"/>
        <span><img src="/signin/image/err.png"/><b>请输入密码</b></span>
        <!--<b id="mitit">长度为6-16个字符，必须包含字母、数字、符号中至少2种</b>-->
    </p>
    <p class="pwd2">
        <label>再次输入：</label>
        <input type="text" id="pass2"/>
        <span><img src="/signin/image/err.png"/><b>两次输入的密码不一致</b></span>
    </p>
    <p><input id="sub" type="button" value="确认修改"/><label> </label><input id="home" type="button" value="返回"/></p>
</form>
<script src="/signin/js/jQuery.3.3.1.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    function getCookie(c_name) {
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(c_name + "=");
            if (c_start != -1) {
                c_start = c_start + c_name.length + 1;
                c_end = document.cookie.indexOf(";", c_start);
                if (c_end == -1) {
                    c_end = document.cookie.length;
                }
                return unescape(document.cookie.substring(c_start, c_end));
            }
        }
        return "";
    }

    $(function () {
        $("#sub").click(function () {
            var pass1 = $('#pass1').val();
            var pass2 = $('#pass2').val();
            if (pass1 == '') {
                err('.pwd1', '密码不能为空')
            } else {
                $('.pwd1').removeClass('err')
                if (pass2 == '') {
                    err('.pwd2', '请再次输入密码')
                } else {
                    $('.pwd2').removeClass('err')
                    var mail = {
                        password1: pass1,
                        password2: pass2
                    }
                    $.ajax({
                        url: '/signin/user/editPasswd',
                        type: 'POST',
                        data: mail,
                        beforeSend: function (xhr) {
                            xhr.setRequestHeader("tmp_token", getCookie("tmp_token"));
                        },
                        success: function (result) {
                            console.log(result.code);
                            if (result.code == 200) {

                                localStorage.removeItem('admin');
                                window.location.href = '/signin/user/password/success';
                            } else {
                                err('.pwd2', result.message);
                            }
                        },
                        error: function () {
                        }
                    })
                }
            }


        })


        $('#home').click(function () {
            $.post("/signin/user/gohome", null, function (result) {
                window.location.href = result.result;
            });

        })

        function err(name, txt) {
            $(name).addClass('err');
            $(name).find('b').html(txt)
        }
    })


</script>
</body>
</html>
